package com.org.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import com.org.IbatisBaseDao;
import com.org.dao.IQqEmailDao;
import com.org.model.Qqemail;
@Component
@SuppressWarnings("all")
public class QqEmailDaoImpl extends IbatisBaseDao implements IQqEmailDao {
	private Logger logger=Logger.getLogger(QqEmailDaoImpl.class);
	
	public Map<String, Object> getQqEmailLists(Map<String, Object> params) {
		Map<String, Object> result;
		try {
			result = new HashMap<String, Object>();
			Integer total = (Integer) sqlMapClient.queryForObject("findQQEmailCount", params);
			List queryForList = sqlMapClient.queryForList("findQQEmailLists", params);
			List<Map<String, Object>> list = queryForList;
			result.put("total", total);
			result.put("list", list);
			return result;
		} catch (Exception e) {
			logger.info("find QqEmailLists"+ e.getMessage());
			e.printStackTrace();
		}
		return null;
	
	}

	public Qqemail getEmailById(String primaryKey) {
		Qqemail qqemail=(Qqemail)getSqlMapClientTemplate().queryForObject("findQQEmailById", primaryKey);
		qqemail=(qqemail==null)?new Qqemail():qqemail;
		return qqemail;
	}
	
	public void updateEmailById(Qqemail entity){
		getSqlMapClientTemplate().update("updateEmailById", entity);
	}

	public void insertEmail(Qqemail entity) {
		//sqlMapClient.insert("insertEmail", entity);
		getSqlMapClientTemplate().insert("insertEmail", entity);
	}

	@Override
	public boolean getIsExistEmail(String email) {
		boolean flag=Boolean.FALSE;
		List<Qqemail> lists=getSqlMapClientTemplate().queryForList("findIsExistEmail", email);
		if(lists!=null&&lists.size()>0){
			return true;
		}else{
			return flag;
		}  
	}

	@Override
	public void deleteEmailById(String primaryKey) {
		getSqlMapClientTemplate().delete("deleteEmailById", primaryKey);
	}
}
